package top.rainf.service.impl;

import org.springframework.stereotype.Service;
import top.rainf.service.IAuthorityService;
import top.rainf.support.Result;
import top.rainf.support.TokenGenerator;

/**
 * @author 星环
 * @date 2023/5/24 0:39:39
 * @description
 */
@Service
public class AuthorityService implements IAuthorityService {

    @Override
    public String checkUserLogin(String token, int userId) {
        if (token == null){
            return "未登录，请登录再发帖！";
        }
        int userIdFromToken = TokenGenerator.getUserIdFromToken(token);
        if (userIdFromToken != userId){
            return "登录凭证与用户id不符！";
        }
        return "";
    }
}
